package reggie.ruiji.mapper;


import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import reggie.ruiji.pojo.SetmealDish;

import java.util.List;

@Mapper
public interface SetmealdishMapper {


    @Insert("<script>" +
            "insert into setmeal_dish(dish_id, name, price, create_time, update_time, create_user, update_user ,copies, setmeal_id) values " +
            "<foreach collection='list' item='item' separator=','>" +
            "(#{item.dishId}, #{item.name}, #{item.price}, #{item.createTime}, #{item.updateTime}, #{item.createUser}, #{item.updateUser}, #{item.copies}, #{item.setmealId})" +
            "</foreach>" +
            "</script>")
    public void insert(List<SetmealDish> list);



    @Delete("<script>" +
            "delete from setmeal_dish where setmeal_id in " +
            "<foreach collection='list' item='item' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach>" +
            "</script>"
    )
    public void delete(List<Long> list);

    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    public List<SetmealDish> getBySetmealId(Long id);


}
